<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: {2021/1/11}
 * Time: {15:09}
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\admin\middleware;


use think\Response;

class Check
{
    public function handle($request, \Closure $next)
    {
        $pathInfo = $request->pathinfo();
        $getSession = session(config('admin.admin_session_key'));
        //dump($getSession);exit();

        if (empty($getSession) && !preg_match('/login/', $pathInfo)) {
            //dump("asf");exit();
            return redirect((string)url('login/index'));
        }
        //前置中间件
        $response = $next($request);
        //后置中间件
        $request->controller;
        return $response;
    }

    public function end(Response $response)
    {

    }
}